<template>

<UserForm @onSubmit="onSubmit"  />

</template>

<script>
import UserForm from '@/components/UserForm.vue'
import { loginAPI } from '@/api/user'
import { setToken } from '@/utils/storage'
export default {
  name: 'LoginPage',
  data () {
    return {

    }
  },
  components: {
    UserForm
  },
  methods: {
    async onSubmit (values) {
      // 3. 封装登录API 调用登录接口
      const res = await loginAPI(values)
      // 4.登录成功 : 提示用户 存token 跳转到首页
      this.$toast('登录成功')
      setToken(res.data.token)
      this.$router.push('/')
    }

  }
}
</script>

<style lang="less" scoped>
.link {
  color: rgb(48, 43, 183);
  background-color: #27BE6F;
  font-size: 18px;
  padding-right: 20px;
  float: right;
  border: none;
  font-weight: 900;
}
</style>
